package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import org.antlr.v4.runtime.misc.NotNull;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SourceAliasContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.StreamSourceContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.UnidirectionContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.StreamBodyContext;

/**
 * from 子句中流相关的语法内容
 * @author zwd
 *
 */
public class StreamBodyVisitor extends AbsCQLParserBaseVisitor<StreamBodyContext>{

	private StreamBodyContext context = null;
	
	public StreamBodyVisitor() {
		context = new StreamBodyContext();
	}
	
	@Override
	protected StreamBodyContext defaultResult() {
		return context;
	}
	
	@Override
	public StreamBodyContext visitStreamSource(@NotNull StreamSourceContext ctx) {
		StreamSourceVisitor visitor = new StreamSourceVisitor();
        context.setStreamSource(visitor.visit(ctx));
        return context;
	}
	
	
	@Override
	public StreamBodyContext visitSourceAlias(@NotNull SourceAliasContext ctx) {
		SourceAliasVisitor visitor = new SourceAliasVisitor();
        context.setAlias(visitor.visit(ctx));
        return context;
	}
	
	@Override
	public StreamBodyContext visitUnidirection(@NotNull UnidirectionContext ctx) {
		context.setUnidirection(true);
        return context;
	}

}
